class Utils {

    /**
     * 只返回生成好的路由配置文件
     */
    CreatedRouter() {
        let role = JSON.parse(localStorage.getItem("qx")),
            RouterArr = [];

        RouterArr.push({
            path: '/',
            name: 'layout',
            component: () => import('../views/Layout.vue'),
            children: []
        });

        role.forEach(v => {
            v.children.forEach(k => {
                //RouterArr[0]为对象再.children追加到\router\index的layout的children中
                //解决点击左侧菜单跳转没有导航条的问题
                RouterArr[0].children.push({
                    path: v.path + k.path,
                    name: `${this.GetRouterName(v.path)}_${this.GetRouterName(k.path)}`,
                    component: () => import(`../views${v.path}${k.path}.vue`),
                    meta: {
                        isLogin: true
                    }
                })
            })
        });
        //返回到页面调用RouterArr方法 created() {this.CreatedRouter()},
        console.log(RouterArr,99)
        return RouterArr;
    }

    GetRouterName(str) {
        return str.split("/")[1]
    }

}

export default new Utils();